//
// Created by y on 2017-12-17.
//

#ifndef PLAYER_VIDEO_H
#define PLAYER_VIDEO_H


#include "BasePlayer.h"
#include "Queue.h"
#include "JavaCall.h"
#include "Log.h"
#include "Audio.h"

extern "C"
{
    #include <libavutil/time.h>
};

class VideoPlayer : public BasePlayer{

public:
    Queue *queue = NULL;
    AudioPlayer *Audio = NULL;
    WlPlayStatus *PlayStatus = NULL;
    pthread_t videoThread;
    pthread_t decFrame;
    JavaCallFunc *wljavaCall = NULL;

    double delayTime = 0;
    int rate = 0;
    bool isExit = true;
    bool isExit2 = true;
    int codecType = -1;
    double video_clock = 0;
    double framePts = 0;
    bool frameratebig = false;
    int playcount = -1;

public:
    VideoPlayer(JavaCallFunc *javaCallFunc, AudioPlayer *audio, WlPlayStatus *playStatus);
    ~VideoPlayer();

    void playVideo(int codecType);
    void decodVideo();
    void release();
    double synchronize(AVFrame *srcFrame, double pts);
    double getDelayTime(double diff);
    void setClock(int secds);
};
#endif //PLAYER_VIDEO_H
